package com.blank.task11;

import java.util.*;

public class PlayingCard {
    //私有化成员变量
    //准备一个map集合用来存储扑克牌 eg:3-梅花A
    private static Map<Integer,String> m1 = new HashMap<>();
    //准备一个list用来表示索引  1~54
    private static List<Integer> li = new ArrayList<>();

    private static String[] str1 = {"大王","小王","2","A","3","4","5","6","7","8","9","10","J","Q","K"};
    private static String[] str2 = {"♠","♥","♣","♦"};
    private static int index = 1;

    public PlayingCard() {
    }

    public static Map<Integer, String> getM1() {
        return m1;
    }

    public static void setM1(Map<Integer, String> m1) {
        PlayingCard.m1 = m1;
    }

    public static List<Integer> getLi() {
        return li;
    }

    public static void setLi(List<Integer> li) {
        PlayingCard.li = li;
    }

    public static String[] getStr1() {
        return str1;
    }

    public static void setStr1(String[] str1) {
        PlayingCard.str1 = str1;
    }

    public static String[] getStr2() {
        return str2;
    }

    public static void setStr2(String[] str2) {
        PlayingCard.str2 = str2;
    }

    public static int getIndex() {
        return index;
    }

    public static void setIndex(int index) {
        PlayingCard.index = index;
    }

    public static List<Integer> getPlayerA() {
        return playerA;
    }

    public static void setPlayerA(List<Integer> playerA) {
        PlayingCard.playerA = playerA;
    }

    public static List<Integer> getPlayerB() {
        return playerB;
    }

    public static void setPlayerB(List<Integer> playerB) {
        PlayingCard.playerB = playerB;
    }

    public static List<Integer> getPlayerC() {
        return playerC;
    }

    public static void setPlayerC(List<Integer> playerC) {
        PlayingCard.playerC = playerC;
    }

    public static List<Integer> getHandCard() {
        return handCard;
    }

    public static void setHandCard(List<Integer> handCard) {
        PlayingCard.handCard = handCard;
    }

    //起始索引值
    public static  void setCardValue(){
        for(int i=0;i<str1.length;i++){
            for(int j=0;j<str2.length;j++){
                li.add(index);
                if(i<2){
                    m1.put(index,str1[i]);
                    index++;
                    break;
                }else{
                    m1.put(index,str2[j]+str1[i]);
                    index++;
                }
            }
        }
    }
    //打印纸牌
    public static void showCard(){
        Set<Map.Entry<Integer,String>> entries = m1.entrySet();
        for(Map.Entry<Integer,String> value :entries){
            System.out.print(value+" ");
        }
    }
    //洗牌阶段
    public static void shuffleCards(){
        Collections.shuffle(li);
    }
    //玩家A
    private static List<Integer> playerA = new ArrayList<>();
    //玩家B
    private static List<Integer> playerB = new ArrayList<>();
    //玩家C
    private static List<Integer> playerC = new ArrayList<>();
    //底牌
    private static List<Integer> handCard = new ArrayList<>();
    //发牌阶段
   public static void dealCards(){
       for (int i=0;i<li.size();i++){
           int cardValue = li.get(i);
           if(i<3){
               handCard.add(cardValue);
           }else if(1 == i%3){
               for(int k=0;k<3;k++){
                   playerA.add(cardValue);
                   break;
               }
           }else if(2 == i%3){
               for(int k=0;k<3;k++){
                   playerB.add(cardValue);
                   break;
               }
           }else{
               for(int k=0;k<3;k++){
                   playerC.add(cardValue);
                   break;
               }
           }
       }
   }
   //排序阶段
    public static void sortCard(){
        Collections.sort(playerA);
        Collections.sort(playerB);
        Collections.sort(playerC);
        Collections.sort(handCard);
    }
    //展示玩家的手中的扑克牌和底牌
    public static void showFinalCard(List<Integer> l){
        for(Integer integer :l){
            System.out.print(m1.get(integer)+" ");
        }
    }


}
